#include <tile.h>

Tile::Tile() {
	flgWall = false;
	flgSensor = false;
	flgImportant = false;
	beams = 0;
	sensor = SENSOR_NO;
}

const int Tile::getBeams() const {
	return beams;
}

const Sensor Tile::getSensor() const {
	return (flgSensor)? sensor : SENSOR_NO;
}

const bool Tile::hasSensor() const {
	return flgSensor;
}

const bool Tile::isWall() const {
	return flgWall;
}

const bool Tile::isImportant() const {
	return (!flgWall)? flgImportant : false;
}

const bool Tile::isCovered() const {
	return (!flgWall)? ((flgImportant)? (beams > 1) : (beams > 0)) : true;
}

const bool Tile::isAvailable() const {
	return (!flgWall && !flgSensor && !isCovered() && !flgImportant);
}

void Tile::setSensor(const Sensor s) {
	flgSensor = true;
	sensor = s;
	beams += 1;
	if(sensor == SENSOR_FD)	beams += 1;
}

void Tile::setWall() {
	flgWall = true;
}

void Tile::setImportant() {
	flgImportant = true;
}

void Tile::setBeams(const int b) {
	beams = b;
}

void Tile::clearSensor() {
	flgSensor = false;
	beams -= 1;
	if(sensor == SENSOR_FD)	beams -= 1;
	sensor = SENSOR_NO;
}
